News All Tests
Current file: /home/estudydev/workspace/MSP09/web/news/tests/class.teamlist.inc.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 6
4.17 %4.17%
4.17% 3 / 72
 
TeamList
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 6
1.43 %1.43%
1.43% 1 / 70
 public function listTeams($teams)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 29
 public function getTeams($courseID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 12
 public function countTeams($courseID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 5
 public function showDateForm($courseID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 12
 public function getTeamClosingDate($courseID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 5
 public function setTeamClosingDate($courseID, $timestamp)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 6


       1                 : <?php                                                                                                                                                                                                                                                                                                                 
       2                 : /*--------------------------------------------------------------------------+                                                                                                                                                                                                                                         
       3                 : This file is part of eStudy.                                                                                                                                                                                                                                                                                          
       4                 : teams/classes/class.teamlist.inc.php                                                                                                                                                                                                                                                                                  
       5                 : - Modulgruppe:  Teams                                                                                                                                                                                                                                                                                                 
       6                 : - Beschreibung: Klasse zum Auflisten von Teams in Kursen.                                                                                                                                                                                                                                                             
       7                 : - Version:      0.3, 18/11/06                                                                                                                                                                                                                                                                                         
       8                 : - Autor(en):    Clemens Weiß <clemens.weiss@mni.fh-giessen.de>                                                                                                                                                                                                                                                       
       9                 : +---------------------------------------------------------------------------+                                                                                                                                                                                                                                         
      10                 : This program is free software; you can redistribute it and/or                                                                                                                                                                                                                                                         
      11                 : modify it under the terms of the GNU General Public License                                                                                                                                                                                                                                                           
      12                 : as published by the Free Software Foundation; either version 2                                                                                                                                                                                                                                                        
      13                 : of the License, or any later version.                                                                                                                                                                                                                                                                                 
      14                 : +---------------------------------------------------------------------------+                                                                                                                                                                                                                                         
      15                 : This program is distributed in the hope that it will be useful,                                                                                                                                                                                                                                                       
      16                 : but WITHOUT ANY WARRANTY; without even the implied warranty of                                                                                                                                                                                                                                                        
      17                 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                                                                                                                                                                                                                                         
      18                 : GNU General Public License for more details.                                                                                                                                                                                                                                                                          
      19                 : You should have received a copy of the GNU General Public License                                                                                                                                                                                                                                                     
      20                 : along with this program; if not, write to the Free Software                                                                                                                                                                                                                                                           
      21                 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                                                                                                                                                                                                                                           
      22                 : +--------------------------------------------------------------------------*/                                                                                                                                                                                                                                         
      23                 : /**                                                                                                                                                                                                                                                                                                                   
      24                 :  * Klasse zum Auflisten von Teams in Kursen.                                                                                                                                                                                                                                                                          
      25                 :  * @package eStudy.Teams                                                                                                                                                                                                                                                                                              
      26                 :  * @version 0.3, 18/11/06                                                                                                                                                                                                                                                                                             
      27                 :  * @author Clemens Weiß <clemens.weiss@mni.fh-giessen.de>                                                                                                                                                                                                                                                            
      28                 :  */                                                                                                                                                                                                                                                                                                                   
      29               1 : require_once ("class.team.inc.php");                                                                                                                                                                                                                                                                                  
      30               1 : require_once ("class.dateselection.inc.php");                                                                                                                                                                                                                                                                         
      31               1 : class TeamList {                                                                                                                                                                                                                                                                                                      
      32                 :     /**                                                                                                                                                                                                                                                                                                               
      33                 :      * Gibt ein Formular aus, in dem alle angelegten Teams bearbeitet werden können                                                                                                                                                                                                                                  
      34                 :      * mit einer leeren Zeile zum Neuanlegen.                                                                                                                                                                                                                                                                         
      35                 :      *                                                                                                                                                                                                                                                                                                                
      36                 :      * @static                                                                                                                                                                                                                                                                                                        
      37                 :      * @access public                                                                                                                                                                                                                                                                                                 
      38                 :      * @param array $teams Array von Team-Objekten                                                                                                                                                                                                                                                                    
      39                 :      * @return bool false bei fehlerhaftem Array, sonst true                                                                                                                                                                                                                                                          
      40                 :      */                                                                                                                                                                                                                                                                                                               
      41                 :     function listTeams($teams) {                                                                                                                                                                                                                                                                                      
      42               0 :         if (!is_array($teams)) {                                                                                                                                                                                                                                                                                      
      43               0 :             return false;                                                                                                                                                                                                                                                                                             
      44                 :         }                                                                                                                                                                                                                                                                                                             
      45               0 :         foreach($teams as $team) {                                                                                                                                                                                                                                                                                    
      46               0 :             if (!is_a($team, "Team")) return false;                                                                                                                                                                                                                                                                   
      47               0 :         }                                                                                                                                                                                                                                                                                                             
      48               0 :         if (!(isset($teams[0]) && $teams[0]->getID() == 0)) {                                                                                                                                                                                                                                                         
      49                 :             // wenn gerade ein neues Team angelegt werden soll, die Eingabe aber noch Fehler enthält,                                                                                                                                                                                                                
      50                 :             // keine Zeile für ein weiteres neues Team anfügen                                                                                                                                                                                                                                                      
      51               0 :             $teams[0] = new Team(0);                                                                                                                                                                                                                                                                                  
      52               0 :         }                                                                                                                                                                                                                                                                                                             
      53               0 :         echo "<h2>Teams in diesem Kurs</h2>";                                                                                                                                                                                                                                                                         
      54               0 :         echo "<form action='".PATH_TO_ROOT.SCRIPT_NAME."' method='post'>";                                                                                                                                                                                                                                            
      55               0 :         echo "<table class='tableBorder'>\n";                                                                                                                                                                                                                                                                         
      56               0 :         echo "<tr class='tableHead'>";                                                                                                                                                                                                                                                                                
      57               0 :         echo "<th>L&ouml;schen&nbsp;".Utilities::helpCode(500) ."</th>";                                                                                                                                                                                                                                              
      58               0 :         echo "<th>Name ".Utilities::helpCode(501) ."</th>";                                                                                                                                                                                                                                                           
      59               0 :         echo "<th>Mitgl.&nbsp;".Utilities::helpCode(502) ."</th>";                                                                                                                                                                                                                                                    
      60               0 :         echo "<th>Team-Style ".Utilities::helpCode(503) ."</th>";                                                                                                                                                                                                                                                     
      61               0 :         echo "<th>Team-Logo ".Utilities::helpCode(504) ."</th>";                                                                                                                                                                                                                                                      
      62               0 :         echo "</tr>\n";                                                                                                                                                                                                                                                                                               
      63               0 :         foreach($teams as $teamID => $team) {                                                                                                                                                                                                                                                                         
      64               0 :             $data = null;                                                                                                                                                                                                                                                                                             
      65               0 :             if (isset($_POST["name$teamID"]) && $teamID > 0) {                                                                                                                                                                                                                                                        
      66               0 :                 $data = array("name" => $_POST["name$teamID"], "maxMembers" => $_POST["maxMembers$teamID"], "style" => $_POST["style$teamID"], "logo" => $_POST["logo$teamID"]);                                                                                                                                      
      67               0 :             }                                                                                                                                                                                                                                                                                                         
      68               0 :             $team->echoFormRow($data);                                                                                                                                                                                                                                                                                
      69               0 :         }                                                                                                                                                                                                                                                                                                             
      70               0 :         Output::echoDialogBottom(array("okButton" => "Speichern", "cancelButton" => "",), 5);                                                                                                                                                                                                                         
      71               0 :         echo "</table>\n";                                                                                                                                                                                                                                                                                            
      72               0 :         echo "</form>";                                                                                                                                                                                                                                                                                               
      73               0 :         return true;                                                                                                                                                                                                                                                                                                  
      74                 :     }                                                                                                                                                                                                                                                                                                                 
      75                 :     /**                                                                                                                                                                                                                                                                                                               
      76                 :      * Gibt ein Array mit Team-Objekten für den angegebenen Kurs zurück.                                                                                                                                                                                                                                            
      77                 :      *                                                                                                                                                                                                                                                                                                                
      78                 :      * @static                                                                                                                                                                                                                                                                                                        
      79                 :      * @access public                                                                                                                                                                                                                                                                                                 
      80                 :      * @param int $courseID ID des Kurses                                                                                                                                                                                                                                                                             
      81                 :      * @return mixed false, wenn die Kurs-ID ungültig ist, sonst ein Array mit Team-Objekten                                                                                                                                                                                                                         
      82                 :      */                                                                                                                                                                                                                                                                                                               
      83                 :     function getTeams($courseID) {                                                                                                                                                                                                                                                                                    
      84               0 :         global $db, $settings;                                                                                                                                                                                                                                                                                        
      85               0 :         $dbp = $settings["dbPrefix"];                                                                                                                                                                                                                                                                                 
      86               0 :         if (strval(intval($courseID)) != $courseID || $courseID < 0) {                                                                                                                                                                                                                                                
      87               0 :             return false;                                                                                                                                                                                                                                                                                             
      88                 :         }                                                                                                                                                                                                                                                                                                             
      89               0 :         $teams = array();                                                                                                                                                                                                                                                                                             
      90               0 :         $teamIDs = $db->get_col("SELECT id FROM {$dbp}teams WHERE course_id='$courseID' ORDER BY name");                                                                                                                                                                                                              
      91               0 :         if (!empty($teamIDs)) {                                                                                                                                                                                                                                                                                       
      92               0 :             foreach($teamIDs as $teamID) {                                                                                                                                                                                                                                                                            
      93               0 :                 $teams[(int)$teamID] = new Team($teamID);                                                                                                                                                                                                                                                             
      94               0 :             }                                                                                                                                                                                                                                                                                                         
      95               0 :         }                                                                                                                                                                                                                                                                                                             
      96               0 :         return $teams;                                                                                                                                                                                                                                                                                                
      97                 :     }                                                                                                                                                                                                                                                                                                                 
      98                 :     /**                                                                                                                                                                                                                                                                                                               
      99                 :      * Gibt die Anzahl der Teams für den angegebenen Kurs zurück                                                                                                                                                                                                                                                    
     100                 :      *                                                                                                                                                                                                                                                                                                                
     101                 :      * @static                                                                                                                                                                                                                                                                                                        
     102                 :      * @access public                                                                                                                                                                                                                                                                                                 
     103                 :      * @param int $courseID ID des Kurses                                                                                                                                                                                                                                                                             
     104                 :      * @return mixed int Anzahl der Teams oder false bei ungültiger Kurs-ID                                                                                                                                                                                                                                          
     105                 :      */                                                                                                                                                                                                                                                                                                               
     106                 :     function countTeams($courseID) {                                                                                                                                                                                                                                                                                  
     107               0 :         global $db, $settings;                                                                                                                                                                                                                                                                                        
     108               0 :         $dbp = $settings["dbPrefix"];                                                                                                                                                                                                                                                                                 
     109               0 :         if (strval(intval($courseID)) != $courseID || $courseID < 0) {                                                                                                                                                                                                                                                
     110               0 :             return false;                                                                                                                                                                                                                                                                                             
     111                 :         }                                                                                                                                                                                                                                                                                                             
     112               0 :         return (int)$db->get_var("SELECT COUNT(*) FROM {$dbp}teams WHERE course_id='$courseID'");                                                                                                                                                                                                                     
     113                 :     }                                                                                                                                                                                                                                                                                                                 
     114                 :     /**                                                                                                                                                                                                                                                                                                               
     115                 :      *                                                                                                                                                                                                                                                                                                                
     116                 :      */                                                                                                                                                                                                                                                                                                               
     117                 :     function showDateForm($courseID) {                                                                                                                                                                                                                                                                                
     118               0 :         $timestamp = TeamList::getTeamClosingDate($courseID);                                                                                                                                                                                                                                                         
     119               0 :         if ($timestamp <= 0) {                                                                                                                                                                                                                                                                                        
     120               0 :             $timestamp = time();                                                                                                                                                                                                                                                                                      
     121               0 :         }                                                                                                                                                                                                                                                                                                             
     122               0 :         $ds = new DateSelection(date("d", $timestamp), date("m", $timestamp), date("Y", $timestamp));                                                                                                                                                                                                                 
     123               0 :         $ds->clearStrings();                                                                                                                                                                                                                                                                                          
     124               0 :         echo "<p>W&auml;hlen Sie hier aus, bis zu welchem Datum die Kursteilnehmer ihre Teamauswahl noch &auml;ndern k&ouml;nnen. Nach diesem Zeitpunkt k&ouml;nnen sich die Mitglieder zwar noch f&uuml;r ein Team entscheiden, die Team-Zuordnung kann danach aber nur noch vom Dozenten ge&auml;ndert werden.</p>";
     125               0 :         echo "<form action='".PATH_TO_ROOT.SCRIPT_NAME."' method='post'>";                                                                                                                                                                                                                                            
     126               0 :         $ds->printCalender("date", "dateExt");                                                                                                                                                                                                                                                                        
     127               0 :         echo " <input type='submit' name='saveDate' value='Speichern' />";                                                                                                                                                                                                                                            
     128               0 :         echo "</form>";                                                                                                                                                                                                                                                                                               
     129               0 :     }                                                                                                                                                                                                                                                                                                                 
     130                 :     function getTeamClosingDate($courseID) {                                                                                                                                                                                                                                                                          
     131               0 :         global $db, $settings;                                                                                                                                                                                                                                                                                        
     132               0 :         $dbp = $settings["dbPrefix"];                                                                                                                                                                                                                                                                                 
     133               0 :         if (strval(intval($courseID)) != $courseID || $courseID <= 0) {                                                                                                                                                                                                                                               
     134               0 :             return 0;                                                                                                                                                                                                                                                                                                 
     135                 :         }                                                                                                                                                                                                                                                                                                             
     136               0 :         return (int)$db->get_var("SELECT team_closing_date FROM {$dbp}courses WHERE ID='$courseID'");                                                                                                                                                                                                                 
     137                 :     }                                                                                                                                                                                                                                                                                                                 
     138                 :     function setTeamClosingDate($courseID, $timestamp) {                                                                                                                                                                                                                                                              
     139               0 :         global $db, $settings, $EZSQL_ERROR;                                                                                                                                                                                                                                                                          
     140               0 :         $dbp = $settings["dbPrefix"];                                                                                                                                                                                                                                                                                 
     141               0 :         if (strval(intval($courseID)) != $courseID || $courseID <= 0 || strval(intval($timestamp)) != $timestamp) {                                                                                                                                                                                                   
     142               0 :             return false;                                                                                                                                                                                                                                                                                             
     143                 :         }                                                                                                                                                                                                                                                                                                             
     144               0 :         $db->query("UPDATE {$dbp}courses SET team_closing_date='$timestamp' WHERE ID='$courseID'");                                                                                                                                                                                                                   
     145               0 :         return $db->rows_affected == 1;                                                                                                                                                                                                                                                                               
     146                 :     }                                                                                                                                                                                                                                                                                                                 
     147                 : }                                                                                                                                                                                                                                                                                                                     

Generated by PHPUnit 3.2.21 and Xdebug 2.0.4 at Sat Nov 7 22:04:08 CET 2009.